package secure;

public class Demo5 {
    public static void main(String[] args) {
        Object lock = new Object();
        Thread t1 = new Thread(() -> {
            synchronized (lock){
                System.out.println("wait 前");
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("wait 后");

            }
        });

        Thread t2 = new Thread(() -> {
            synchronized (lock){
                System.out.println("notify 前");
                lock.notify();
                System.out.println("notify 后");
            }
        });
        t1.start();
        t2.start();
    }
}
